package com.glorysoft.xztpda.bindingadapter

import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.glorysoft.xztpda.entity.EdcDataEDCSETLISTEDCSETBINLINELIST
import com.glorysoft.xztpda.entity.LotBinData
import java.lang.NumberFormatException
import java.text.NumberFormat

/**
 * FileName: NumEditextAdapter
 * Author: XJH
 * Date: 2022/4/28 18:34
 * Description:
 * History:
 */
object BinTextAdapter {

    @BindingAdapter(value = ["binText"], requireAll = false)
    @JvmStatic
    fun setBinText(textView: TextView, item: LotBinData) {
        if (item.MAINQTY == 0) {
            try {
                val numberFormat = NumberFormat.getInstance()
                numberFormat.maximumFractionDigits = 2
                val binQty = item.MAINQTY.toFloat()
//                val mainqty = item.LotQTY
//                val result =
//                    (numberFormat.format((binQty.div(mainqty.toFloat()) * 100)))
//                textView.text = "$result%"
            }catch (e : Exception){
                textView.text = "0.0%"
            }
        }else{
            textView.text = "0.0%"
        }
    }
}